package com.mall.admin.controller;

import cn.hutool.core.convert.Convert;
import com.mall.admin.service.UmsResourceCategoryService;
import com.mall.commons.utils.R;
import com.mall.domain.UmsResource;
import com.mall.domain.UmsResourceCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/resourceCategory")
public class UmsResourceCategoryController {
     @Autowired
    private UmsResourceCategoryService umsResourceCategoryService;
     @PostMapping("/create")
    public R create(@RequestBody UmsResourceCategory umsResourceCategory){
      return umsResourceCategoryService.create(umsResourceCategory);
     }
    @PostMapping("/delete/{id}")
    public R delete(@PathVariable Integer id){
         return umsResourceCategoryService.delete(id);
    }
    @GetMapping("listAll")
    public R listAll(){
     return   umsResourceCategoryService.listAll();
    }
    @PostMapping("/update/{id}")
    public  R update(@PathVariable Integer id, @RequestBody UmsResourceCategory umsResourceCategory){
       umsResourceCategory.setId(Convert.toLong(id));
       return umsResourceCategoryService.update(umsResourceCategory);
    }


}
